{% extends 'base.html' %}
{% block content %}
<html>
<head>
    <script type="text/javascript">
        function fail_text(obj) {
            var pr = obj.parentNode.children[1].id;
            var ds = document.getElementById(pr);
            if(ds.style.display=='block')
                ds.style.display='none';
           else
                ds.style.display='block';
        }
        function show_detail() {
           document.getElementById('detail').style.display='block';
        }
        function hide_detail() {
           document.getElementById('detail').style.display='none';
        }
    </script>
    <style type="text/css">
        .fail_text{display: none}
        #detail{width: 900px}
        .all{
            width: 130px;
        }
        .case{
            width: 200px;
        }
        #case_detail{
            width: 900px;
        }
        .case_result{
            width: 500px;
        }
    </style>
</head>
<body>
<div class="head">
    <h2>测试报告</h2>
    <p>开始时间：<nobr>{{ start_time }}</nobr></p>
    <p>结束时间：<nobr></nobr>{{ end_time }}</p><br>
</div>
<div class="detail">
    <p>测试详情</p>
    <table id="case_detail" border="2" cellpadding="8" style="border-collapse: collapse">
        <tr>
            <td class="all">用例组</td>
            <td class="all">总用例数</td>
            <td class="all">通过数量</td>
            <td class="all">失败数量</td>
            <td class="all">错误数量</td>
            <td class="show">
                <a href="javascript:" onclick="show_detail()">查看</a>
                <a href="javascript:" onclick="hide_detail()">收起</a>
            </td>
        </tr>
        <tr>
            <td class="all">total</td>
            <td class="all">{{ num }}</td>
            <td class="all">{{ succ_num }}</td>
            <td class="all">{{ fail_num }}</td>
            <td class="all">0</td>
            <td class="show">全部 通过 失败 错误</td>
        </tr>
    </table>
    <table id="detail" border="2" cellpadding="8" style="border-collapse: collapse">
        <tr>
            <td class="case">用例ID</td>
            <td class="case">用例名称</td>
            <td class="case_result">测试结果</td>
        </tr>
        {% for i in range(lenth) %}
        <tr class="case_result" id="case_result">
            <td class="case">{{ results[i][0]}}</td>
            <td class="case">{{ results[i][1] }}</td>
            {% if results[i][2] == 'fail' %}
            <td class="case_result">
                <a href="javascript:" onclick="fail_text(this)">{{ results[i][2] }}</a>
                <div class="fail_text" id="fail_{{ i }}">{{ results[i][3] }}</div>
            </td>
            {% else %}
            <td class="case_result" id="succ"  colspan="2">{{ results[i][2] }}</td>
            {% endif %}
        </tr>
        {% endfor %}
    </table>
</div>
</body>
</html>
{% endblock %}